<?php

defined('API_VERSION') or define('API_VERSION', "1.0");
$accept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
if($accept){
	$acceptArr = explode(";",$accept);
	foreach($acceptArr as $item){
		if(strpos($item,"version")!== FALSE){
			$versionArr = explode("=",$item);
			if(strlen($versionArr[1])>0){
				$version = $versionArr[1];
				define('API_VERSION', $version);
			}
			break;
		}
	}
}
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');

$config = require(__DIR__ . '/../config/web.php');

//2015-03-25 add by hetao： 增加网站调用和REST API调用的判断
if(isset($_POST["web"])) //网站include调用
{
	new yii\web\Application($config);
}else{ // REST api 调用
	(new yii\web\Application($config))->run();
	
}


